﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Reflection;
using System.Windows.Forms;

namespace shopsoft.Common
{
    public class PubConfig
    {
        #region Private Attribute

        private XmlProvider XController;
        private string root = "Config/";
        private string ApplicationPath = Application.StartupPath;

        #endregion Private Attribute

        #region Structure Method

        /// <summary>
        /// 
        /// </summary>
        public PubConfig()
        {
            string XmlPath = ApplicationPath + @"\SysConfig\Public.xml";
            XController = new XmlProvider(XmlPath);
        }

        #endregion Structure Method

        #region Private Method

        /// <summary>
        /// 获取指定节点路径的Value值
        /// </summary>
        /// <param name="nodePath">节点路径</param>
        /// <returns></returns>
        private string GetValue(string strNodePath)
        {
            return XController.GetNodeAttributeValue(strNodePath, "value");
        }

        /// <summary>
        /// 获取指定节点路径的指定属性值
        /// </summary>
        /// <param name="strNodePath">节点路径</param>
        /// <param name="attributeName">属性名称</param>
        /// <returns></returns>
        private string GetValue(string strNodePath, string strAttributeName)
        {
            return XController.GetNodeAttributeValue(strNodePath, strAttributeName);
        }

        #endregion Private Method

        #region Public Attribute

        /// <summary>
        /// 数据库连接字符串
        /// </summary>
        public string DbConString
        {
            get { return GetValue(root + "DbConString"); }
        }

        /// <summary>
        /// DES的默认密钥
        /// </summary>
        public string DesDefaultKey
        {
            get { return GetValue(root + "DesDefaultKey"); }
        }

        /// <summary>
        /// 默认语言类型
        /// </summary>
        public string DefaultLanguage
        {
            get { return GetValue(root + "DefaultLanguage"); }
        }

        #endregion
    }
}
